/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-13
 * Time: 17:57
 */
//每日一题  组队竞赛
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int array[] = new int[3 * n];
            long sum = 0;
            for (int i = 0; i < 3 * n; i++) {
                array[i] = scanner.nextInt();
            }
            for (int i = 0; i < n; i++) {
                sum += array[array.length - 2 * (i + 1)];

            }
            System.out.println(sum);

        }

    }
}
